package com.liao.starapp.user;

import android.annotation.SuppressLint;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import com.liao.starapp.R;

public class AboutActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView img_back;
    private TextView tv_title;
    private TextView tv_app_name;
    private TextView tv_version;
    private TextView tv_info;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        initView();
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        getWindow().setStatusBarColor(getColor(R.color.actionBarColor));
    }

    @SuppressLint("SetTextI18n")
    private void initView() {
        img_back = (ImageView) findViewById(R.id.img_back);
        tv_title = (TextView) findViewById(R.id.tv_title);
        tv_app_name = (TextView) findViewById(R.id.tv_app_name);
        tv_version = (TextView) findViewById(R.id.tv_version);
        tv_info = (TextView) findViewById(R.id.tv_info);

        img_back.setOnClickListener(this);
        String info = "\t\t星梦缘一款解析星座的工具,\n"+"功能包括：12星座解析，12星座配对等等";
        tv_info.setText(info);
        tv_title.setText("关于");
        try {
            PackageInfo packageInfo = getPackageManager().getPackageInfo("com.liao.starapp", 0);
            String versionName = packageInfo.versionName;
            tv_version.setText("当前版本：" + versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onClick(View v) {
        onBackPressed();
        finish();
    }
}
